package com.lngsyz.ywtb.biz.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lngsyz.ywtb.entity.source1.GsYwtb;
import com.lngsyz.ywtb.entity.source1.YwtbCityOrder;
import com.lngsyz.ywtb.mapper.source1.GsYwtbMapper;

import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils;

@Service
public class GsYwtbService {
    
	@Autowired
	GsYwtbMapper gsYwtbMapper;
    
    public List<GsYwtb> findByBusinessLicense(String businessLicense){
    	Map<String, Object> param = new HashMap<String, Object>();
    	if(StringUtils.isNotBlank(businessLicense)) {
    		param.put("instCode", businessLicense);
    		List<GsYwtb> lists = gsYwtbMapper.findByCondition(param);
    		return lists;
    	} else {
    		return new ArrayList<GsYwtb>(); 
    	}
    }
    
    public GsYwtb packageYwtb(YwtbCityOrder ywtbCityOrder) {
    	GsYwtb gsYwtb = new GsYwtb();
    	gsYwtb.setBusinessId(ywtbCityOrder.getPripid());
    	gsYwtb.setPripid(ywtbCityOrder.getPripid());
    	gsYwtb.setTradeNo(ywtbCityOrder.getTradeno());
    	gsYwtb.setCompanyId(ywtbCityOrder.getCompanyId());
    	// 从订单获取
    	gsYwtb.setPay(ywtbCityOrder.getPay());
    	gsYwtb.setTotal(ywtbCityOrder.getTotal().toString());
    	gsYwtb.setDeliveryMethod(ywtbCityOrder.getDeliveryMethod());
		gsYwtb.setZfsj(ywtbCityOrder.getZfsj());
    	gsYwtb.setReceiveName(ywtbCityOrder.getReceiveName());
		gsYwtb.setReceiveCertType(ywtbCityOrder.getReceiveCertType());
    	gsYwtb.setReceiveCertNo(ywtbCityOrder.getReceiveCertNo());
    	gsYwtb.setReceivePhone(ywtbCityOrder.getReceivePhone());
    	gsYwtb.setReceiveAddress(ywtbCityOrder.getReceiveAddress());
    	gsYwtb.setName(ywtbCityOrder.getName());
    	gsYwtb.setAddress(ywtbCityOrder.getAddress());
    	gsYwtb.setInstCode(ywtbCityOrder.getInstCode());
    	gsYwtb.setCrpName(ywtbCityOrder.getCrpName());
    	gsYwtb.setCrpCertType(ywtbCityOrder.getCrpCertType());
    	gsYwtb.setCrpCertNo(ywtbCityOrder.getCrpCertNo());
    	gsYwtb.setCrpPhone(ywtbCityOrder.getCrpPhone());
    	gsYwtb.setApName(ywtbCityOrder.getApName());
    	gsYwtb.setApCertType(ywtbCityOrder.getApCertType());
    	gsYwtb.setApCertNo(ywtbCityOrder.getApCertNo());
    	gsYwtb.setApPhone(ywtbCityOrder.getApPhone());
    	gsYwtb.setDistrictCode(ywtbCityOrder.getDistrictCode());
		gsYwtb.setCreateDate(ywtbCityOrder.getCreateDate());
    	gsYwtb.setTrans("1");
    	gsYwtb.setGxsj(ywtbCityOrder.getGmtUpdate());
    	gsYwtb.setTransFk("0");
    	gsYwtb.setBjState("0");
    	gsYwtb.setTradeChannel(ywtbCityOrder.getPayChannel());
    	gsYwtb.setGov("");
    	gsYwtb.setESeal("");
    	gsYwtb.setId(ywtbCityOrder.getId());
    	
    	gsYwtb.setSeal01("0");
    	gsYwtb.setSeal02("0");
    	gsYwtb.setSeal03("0");
    	gsYwtb.setSeal04("0");
    	gsYwtb.setSeal05("0");
    	gsYwtb.setSeal06("0");
    	return gsYwtb;
    }
}
